package com.example.hangzhou.welbeing.mytestdemoapp.animation.animationAdapter;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.example.hangzhou.welbeing.mytestdemoapp.R;

/**
 * 杭州惟君医疗科技有限公司16
 * Created by 20433 on 2018/5/9
 *
 * @desc 东风山河绿，春已不折柳，繁花看不尽，处处惹人留
 * @desc 佛祖镇楼，bug辟容易
 */

public class AnimatedTransitionsExplodeAndPropagationAdapter extends RecyclerView.Adapter<AnimatedTransitionsExplodeAndPropagationAdapter.AnimatedTransitionsExplodeAndPropagationViewHolder> implements View.OnClickListener {

    private OnItemClickListener mOnItemClickListener = null;
    @Override
    public AnimatedTransitionsExplodeAndPropagationViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view =   LayoutInflater.from(parent.getContext()).inflate(R.layout.item_explode_and_propagation, parent, false);
        AnimatedTransitionsExplodeAndPropagationViewHolder holder = new AnimatedTransitionsExplodeAndPropagationViewHolder(view);
        view.setOnClickListener(this);
        return holder;
    }

    @Override
    public void onBindViewHolder(AnimatedTransitionsExplodeAndPropagationViewHolder holder, int position) {
        holder.tv_number.setText(position+"");
    }

    @Override
    public int getItemCount() {
        return 24;
    }

    @Override
    public void onClick(View view) {
        if(mOnItemClickListener != null){
            mOnItemClickListener.onClick(view);
        }
    }

    //自定义ViewHolder，用于加载图片
    class AnimatedTransitionsExplodeAndPropagationViewHolder extends RecyclerView.ViewHolder {

        private final TextView tv_number;

        public AnimatedTransitionsExplodeAndPropagationViewHolder(View view) {
            super(view);
            tv_number = view.findViewById(R.id.item_explode_and_propagation_tv_number);

        }
    }
    public interface OnItemClickListener{
        void onClick( View view);
    }
    public void setOnItemClickListener(OnItemClickListener onItemClickListener ){
        this. mOnItemClickListener =onItemClickListener;
    }

}
